A. Field of the Invention
The present invention relates to a method for image processing, especially to an image compression/decompression method which is bit-based and adaptable to an A/D converter of 12-bit, 14-bit or even more bits.
B. Description of the Prior Art
The primary object of image compression/decompression is to increase the speed of image transmission when communicating between hardware or software. The technology of image compression/decompression for a scanner is especially for increasing the transmission speed between a host computer and a scanner. The scanned image will be converted into digital data by an Analog/Digital converter (A/D converter) for data processing. These digital data are usually compressed before they are sent to the host computer. The compressed data will then be sent to a Random Access Memory (RAM) for the host computer to access. The host computer will then decompress the data read from the RAM and show the restored image on the screen for the user to view or for further processes.
Since an A/D converter of 8-bit is most commonly used in a scanner, conventional reading and processing procedures are based on a unit of 8-bit. Data compression/decompression is also based on the characteristics of the 8-bit data. In other words, for each time when compressing the image data, 8 bits of data can be compressed at the most. The situation is the same for decompression. As the technology of A/D converter has been improved, an A/D converter of 12-bit, 14-bit or even more bits have already been available on the market. Consequently, the conventional image compression/decompression method will not be applicable to such non-8-bit A/D converters. Moreover, when using 8-bit as a processing unit, mosaic effects are often occurred when the fidelity of a decompressed image cannot be fully restored. Furthermore, reading and processing image data of 8-bit a time is apparently not efficient enough because the data size is too small. Such small data sample will also mean low ratio of data repetition.
Accordingly, it is an object of the present invention to provide a method for image compression/decompression which will not generate mosaic effects on the images after the image is decompressed, and which can increase the ratio of data repetition, thereby to improve the speed of image processing.
It is another object of the present invention to provide a method for image compression/decompression which will not be restricted by the bit number of an A/D converter, and adaptable to A/D converters of 12-bit, 14-bit or even more bits.
In accordance with the invention, a new method for data compression and decompression is provided for processing data output of an A/D converter of a scanner. The present invention predetermines the data format for each encoded byte which comprises an attribute field of 2 bits, and a counter field of 6 bits. The attribute field of each encoded byte represents the type of the bits compressed. Since a bit is either 1 or 0, so the attribute field of an encoded byte is enough for distinguishing the bit types. Since the counter field is 6-bit, an encoded byte can record 63 (26xe2x88x921) consecutive high bits/low bits in the counter field at the most. The encoded image data will be output to a RAM for the host computer to access. On the other hand, for image decompression, the host computer will access the RAM. With the predetermined data format, the host computer only need to request the attribute field of each encoded byte to know if the encoded data is a high bit or a low bit or unencoded data. Then, the host computer fills the same number of xe2x80x9c1xe2x80x9ds or xe2x80x9c0xe2x80x9ds into a buffer which can store 63 bytes of data arranged in the same order as the previously defined image blocks. After the buffer is full, the entire data of the buffer will be output to the host computer for further processing.